#ifndef _MOTOR_SPEED_H_
#define _MOTOR_SPEED_H_
#include "bsp_include.h"
#include "motor_run.h"

#define SPEED_MAX           1200
#define SPEED_MIN           0
#define DUTY_MAX            MAX_PWM_CMP
#define DUTY_MIN            50


#define DRUM_MOTOR_KP				70
#define DRUM_MOTOR_KI				100

typedef struct{
    int32_t max_speed;
    int32_t min_speed;
    int32_t target_speed;
    int32_t feedback_speed;
    int32_t max_duty;
    int32_t min_duty;
    int32_t duty;
    int32_t err;
    int32_t err_sum;
    int32_t kp;         //0.01
    int32_t ki;         //0.001
}motor_speed;

extern motor_speed g_drum_speed;

void motor_speed_para_init(motor_speed *_mspd_ptr, uint16_t _kp, uint16_t _ki);
void motor_speed_pi_controller(motor_speed *_mspd_ptr);
void motor_speed_task(void);

#endif /* _MOTOR_SPEED_H_ */
